local kuanggu = fk.CreateSkill({
  name = "lvshi__kuanggu",
  tags = {Skill.Compulsory},
})

Fk:loadTranslationTable{
  ["lvshi__kuanggu"] = "狂骨",
  [":lvshi__kuanggu"] = "锁定技，当你造成伤害后，你回复1点体力；当你回复体力后，你摸一张牌；当你于出牌阶段摸牌后，你于此阶段使用【杀】的次数上限+1。",

  ["$lvshi__kuanggu1"] = "十万之众至，请为大王拒之。",
  ["$lvshi__kuanggu2"] = "魏延在此，汝辈何敢乃尔？",
}

kuanggu:addEffect(fk.Damage, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(kuanggu.name) and player:isWounded()
  end,
  on_use = function(self, event, target, player, data)
    player.room:recover{
      who = player,
      num = 1,
      recoverBy = player,
      skillName = kuanggu.name,
    }
  end,
})

kuanggu:addEffect(fk.HpRecover, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(kuanggu.name)
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, kuanggu.name)
  end,
})

kuanggu:addEffect(fk.AfterCardsMove, {
  mute = true,
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(kuanggu.name) and player.phase == Player.Play then
      for _, move in ipairs(data) do
        if move.to == player and move.moveReason == fk.ReasonDraw then
          return true
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:addPlayerMark(player, "lvshi__kuanggu-turn")
  end,
})

kuanggu:addEffect("targetmod", {
  residue_func = function(self, player, skill, scope)
    if player:getMark("lvshi__kuanggu-turn") > 0 and skill.trueName == "slash_skill" and scope == Player.HistoryPhase then
      return player:getMark("lvshi__kuanggu-turn")
    end
  end,
})

return kuanggu
